<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>4_运算符</title>
</head>
<body>
<script>
    // 比较运算符
    console.log(3>10);
    console.log(3<'10');//3<10
    //比较两边都是字符串,比较字符串的编码值
    console.log('3'>'10');
    console.log('宇'>'博')
    console.log('程晓宇'.charCodeAt(2));
    console.log('博'.charCodeAt());
    // 类型转换,不是数值的为NaN
    console.log(Number(3),typeof Number(3));
    console.log(Number('3'),typeof Number('3'));
    console.log(Number('a'),typeof Number('a'));
    console.log(Number('你好'),typeof Number('你好'));

    let a = 1;
    let b = true;
    //松散比较:只比较值
    console.log(a==b);
    //严格比较:比较值和类型
    console.log(a===b);

    let c = 0;
    console.log(c==0?'yes':'no');//yes
    console.log(c=0?'yes':'no');//no

    console.log(Boolean(0));//false
    console.log(Boolean(null));//false
    console.log(Boolean(undefined));//false
    console.log(Boolean(NaN));//false
    console.log(Boolean(''));//false
    // 以上五个都是false,其他全为ture
    console.log(Boolean(' '));//true
    console.log(Boolean('你好'));//true
</script>

</body>
</html>